package com.lineage.server.command.executor;

import com.lineage.server.model.Instance.L1NpcInstance;
import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.model.L1Object;
import com.lineage.server.serverpackets.S_ServerMessage;
import com.lineage.server.serverpackets.ServerBasePacket;
import com.lineage.server.world.World;
import java.util.Iterator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class L1GfxIdDel implements L1CommandExecutor {
  private static final Log _log = LogFactory.getLog(L1GfxIdDel.class);
  
  public static L1CommandExecutor getInstance() {
    return new L1GfxIdDel();
  }
  
  public void execute(L1PcInstance pc, String cmdName, String arg) {
    try {
      Iterator<L1Object> iterator = World.get().getObject().iterator();
      while (iterator.hasNext()) {
        L1Object object = iterator.next();
        if (object instanceof L1NpcInstance) {
          L1NpcInstance npc = (L1NpcInstance)object;
          if (npc.getNpcId() != 50000)
            continue; 
          npc.deleteMe();
        } 
      } 
    } catch (Exception e) {
      _log.error("错误的GM指令格式: " + getClass().getSimpleName() + " 执行的GM:" + pc.getName());
      pc.sendPackets((ServerBasePacket)new S_ServerMessage(261));
    } 
  }
}
